package com.xinchuang.controller.targetSystem;

import com.alibaba.fastjson.JSONObject;
import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.service.targetSystem.ExportUtil;
import com.xinchuang.service.targetSystem.OfficeUtilService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * TODO
 *
 * @author zkwczx
 * @version 1.0
 * @date 2024/3/21 21:08
 */
@RestController
@RequestMapping(value = "/office")
@RequiredArgsConstructor
public class OfficeController {

    private final OfficeUtilService office;

    private final ExportUtil exportUtil;

    @PostMapping("/getTargetExcelModel")
    public R getTargetExcelModel(@RequestBody JSONObject jsonObject) {
        return office.getTargetExcelModel(jsonObject);
    }

    @PostMapping("/modelToTarget")
    public R getModelToTarget(@RequestParam(value = "imgData") MultipartFile sourceFile) {
//        return office.exportElseTarget(sourceFile);
//        return office.getModelToTarget(sourceFile);
        return exportUtil.exportTarget(sourceFile);
    }

    @PostMapping("/modelToElseTarget")
    public R getModelToElseTarget(
            @RequestParam(value = "typeName") String typeName,
            @RequestParam(value = "imgData") MultipartFile sourceFile) {
        return office.exportElseTarget(typeName, sourceFile);
    }

    @PostMapping("/getEmulation")
    public Result getEmulation(@RequestParam(value = "imgData") MultipartFile sourceFile) {
        return office.exportEmulation(sourceFile);
    }

}
